#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：Employment_class 
@File    ：07_greenle实现多任务.py
@IDE     ：PyCharm 
@Author  ：XiaoDengYa
@Date    ：2021/7/5/005 20:00 
"""

import time

from greenlet import greenlet


def demo1():
    while True:
        print("----A-----")
        gr2.switch()
        print("----A1-----")
        time.sleep(0.5)


def demo2():
    while True:
        print("----B-----")
        gr1.switch()
        print("----B2-----")
        time.sleep(0.5)


if __name__ == '__main__':
    gr1 = greenlet(demo1)
    gr2 = greenlet(demo2)
    gr1.switch()
